#include <Kernel/GlobalData.h>
#include <Memory/Paging.h>
#include <IO/VideoTextMode.h>

/*
@brief 获取内存信息
@note 可用内存空间标记为 Available（蓝色），不可用内存空间标记为 UnAvailable（红色）
*/
void QueryMemoryInfo()
{
    LPAddressRangeDescriptor lpARDS = g_MemoryAddressMap;
    kmessage("Detecting Available Memory Space.\r\n");
    while (lpARDS->dwLengthLow != 0) /* 有效的 ARDS */
    {
        if (lpARDS->dwType == 1) /* 可用内存 */
        {
            VideoTextModeSetColor(VIDEO_TEXT_MODE_FOREGROUND_BLUE);
            printk(
                "0x%x ~ 0x%x, %s\r\n",
                lpARDS->dwlpBaseAddrLow, 
                lpARDS->dwlpBaseAddrLow + lpARDS->dwLengthLow - 1,
                "Available"
            );
            VideoTextModeSetColor(VIDEO_TEXT_MODE_COLOR_INFO);
        }
        else
        {
            kerror(
                "0x%x ~ 0x%x, %s\r\n",
                lpARDS->dwlpBaseAddrLow, 
                lpARDS->dwlpBaseAddrLow + lpARDS->dwLengthLow - 1,
                "UnAvailable"
            );
        }
        lpARDS++;
    }
}